/*
infrastructure 提供技术支持，例如数据库访问、外部Http访问等。
*/
package infrastructure

import (
	"SkyPath/internal/infrastructure/gatewayimpl/dbtools"
	"SkyPath/internal/infrastructure/gatewayimpl/project"
)

func CreateDB() error {
	var infras Infrastructure
	infs := infras.GetConn()
	var dbtoolsFields dbtools.Dbtools
	var distributeFields dbtools.Distribute

	infs.AutoMigrate(&dbtoolsFields)
	infs.AutoMigrate(&distributeFields)

	var Projects project.Projects
	var ProjectItemsInfo project.ProjectItemsInfo
	var ProjectItemsPlan project.ProjectItemsPlan
	var Ledger project.Ledger
	infs.AutoMigrate(&Projects)
	infs.AutoMigrate(&ProjectItemsInfo)
	infs.AutoMigrate(&ProjectItemsPlan)
	infs.AutoMigrate(&Ledger)

	err := infs.Close()
	if err != nil {
		return err
	}
	return nil
}
